package com.nwpu.server.learning.controller;

import com.alibaba.nacos.common.model.RestResultUtils;
import com.nwpu.server.common.response.R;
import com.nwpu.server.learning.entity.SelectEntity;
import com.nwpu.server.learning.service.SelectService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@RequestMapping("learning/select")
public class SelectController {

    @Autowired
    private SelectService selectService;

    @PostMapping("/start")
    public R start(@RequestBody SelectEntity select) {
        List result = selectService.start(select);

        return R.ok().put("select", result);
    }

    @GetMapping("/first")
    public List<String> first() {
        // 第一个条件
        List<String> ans = selectService.selectFirst();
        return ans;
    }

    @GetMapping("/second")
    public List<String> second(@RequestParam(value = "first", required = true) String first) {
        List<String> ans = selectService.selectSecond(first);
        return ans;
    }

    @GetMapping("/getFileName")
    public List<SelectEntity> getFileName(@RequestParam(value = "first", required = true) String first, @RequestParam(value = "second", required = true) String second) {
        List<SelectEntity> ans = selectService.getFileName(first, second);
        return ans;
    }
}
